//
//  UUHybridSelectDriverHandler.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 23/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUHybridSelectDriverHandler.h"
#import "UUDriverPicker.h"
#import "UUDriverManager.h"

@implementation UUHybridSelectDriverHandler

- (NSString *)name {
    return @"selectDriver";
}

- (void)executeWithParams:(id)params callbackWith:(void (^)(id))callback {
    NSNumber *fleetId = params[@"motorcade_id"];
    UIViewController *picker = [UUDriverPicker pickerWithFleetId:fleetId completeBlock:^(id driverId) {
        callback(@{
                   @"driver_id" : driverId,
                   @"driver_name" : [GetDriverManager() fetchDriverWithDriverId:driverId].name
                   });
    }];
    [self.context.hostVC presentViewController:picker animated:YES completion:nil];
}

@end
